<?php
$facebook = new Facebook(array(
    'appId'  => FB_APP_ID,
    'secret' => FB_APP_SECRET
));

//if there is a facebook session in PHP $_SESSION
if(isset($_SESSION['fb_session'])){
    $facebook = $facebook->setSession($_SESSION['fb_session']);
} 

//Still don't know whether the session is valid or not
$session = $facebook->getSession();

//permissions
$perms = 'user_about_me,
friends_about_me,
user_notes,
user_status,
friends_notes,
friends_status,
read_mailbox,
read_stream';

//Buttongs
if($_SERVER['HTTP_HOST'] == "localhost"){
    $logout_button = "<a href='".$facebook->getLogoutUrl()."'><img id='logout_button' src='http://static.ak.fbcdn.net/rsrc.php/z2Y31/hash/cxrz4k7j.gif'></a>";
} else {
    $logout_button = null;
} 
$login_button = "<a href='".$facebook->getLoginUrl(array('req_perms' => $perms))."'><img id='login_button' src='http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif'></a>";
